# -*- coding: utf-8 -*-

from typing import Optional
from fastapi import Query

from app.core.validator import DateTimeStr

class {{ class_name }}QueryParam:
    """{{ function_name }}查询参数"""

    def __init__(
        self,
        {% for column in columns %}
        {% if column.query_type == 'LIKE' %}
        {{ column.column_name }}: Optional[{{ column.python_type }}] = Query(None, description="{{ column.column_comment }}"),
        {% endif %}
        {% endfor %}
        {% for column in columns %}
        {% if column.query_type == 'EQ' %}
        {{ column.column_name }}: Optional[{{ column.python_type }}] = Query(None, description="{{ column.column_comment }}"),
        {% endif %}
        {% endfor %}
        creator: Optional[int] = Query(None, description="创建人"),
        start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2025-01-01 00:00:00"),
        end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2025-12-31 23:59:59"),
    ) -> None:
        
        # 模糊查询字段
        {% for column in columns %}
        {% if column.query_type == 'LIKE' %}
        self.{{ column.column_name }} = ("like", {{ column.column_name }})
        {% endif %}
        {% endfor %}

        # 精确查询字段
        {% for column in columns %}
        {% if column.query_type == 'EQ' %}
        self.{{ column.column_name }} = {{ column.column_name }}
        {% endif %}
        {% endfor %}
        self.creator_id = creator

        # 时间范围查询
        if start_time and end_time:
            self.created_at = ("between", (start_time, end_time))